package com.assessment.repository.impl;

import com.assessment.mapper.AssessmentResultMapper;
import com.assessment.model.entity.AssessmentResult;
import com.assessment.repository.AssessmentResultRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * 评测结果仓储实现类
 */
@Repository
public class AssessmentResultRepositoryImpl implements AssessmentResultRepository {

    @Autowired
    private AssessmentResultMapper resultMapper;

    @Override
    public boolean saveResult(AssessmentResult result) {
        return resultMapper.insert(result) > 0;
    }

    @Override
    public AssessmentResult getTeacherOverallResult(Integer teacherId, Integer periodId) {
        return resultMapper.findTeacherOverallResult(teacherId, periodId);
    }

    @Override
    public List<AssessmentResult> getTeacherCategoryResults(Integer teacherId, Integer periodId) {
        return resultMapper.findTeacherCategoryResults(teacherId, periodId);
    }

    @Override
    public List<AssessmentResult> getDepartmentResults(Integer departmentId, Integer periodId) {
        return resultMapper.findByDepartmentAndPeriod(departmentId, periodId);
    }

    @Override
    public List<AssessmentResult> getAllResults(Integer periodId) {
        // 假设实现一个查询所有结果的方法，这里简化处理
        return resultMapper.selectList(null);
    }
}
